package com.jinghang.scala_base._5_Scala操作外部数据

import scala.io.Source

/**
  * 读取文件操作
  */
object FileApp {


  def main(args: Array[String]): Unit = {

    val bufferedSource = Source.fromFile("data/student.data")//(scala.io.Codec.UTF8)

    def readLine()={
        for (line <- bufferedSource.getLines()){
            println(line)
        }
    }

    //readLine()

    def readChar(): Unit ={
      for(ele <- bufferedSource) {
        println(ele)
      }
    }

       //readChar()

    def readNet(): Unit ={
      val bufferedSource = Source.fromURL("http://www.baidu.com")
      for(line <- bufferedSource.getLines()){
        println(line)
      }
    }

    readNet()
  }

}
